Skip to content

Validate static credentials before client role selection - #312

Merged
rmcdaniel merged 5 commits into
mainfrom
fix/sdk-python-304-static-credentials
Nov 13, 2026
Merged

rmcdaniel merged 5 commits into
mainfrom
fix/sdk-python-304-static-credentials

Conversation

@rmcdaniel

@rmcdaniel rmcdaniel commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Refs #304.

A token copied from a Secret file with a trailing newline currently reaches HTTP and produces repeated 401s. Validate every supplied token, control_token and worker_token during construction, before role selection. Refuse edge whitespace or control characters without trimming or exposing any value. Preserve None, empty strings and existing role precedence.

Copies the canonical Server credential fixture unchanged. Its common Unicode scalar cases cover every token option, and its pre-selection vectors cover masked or unused malformed tokens. Additional checks preserve empty/None behavior, discovery order and role precedence.

Validation: the new test fails on current main because the constructor accepts a leading tab. With the fix, 1,108 shared-vector and client tests pass; Ruff, mypy and the public-boundary scan pass. GitHub CI remains required before merge. Publication and installed-package verification will be recorded on #304.

@rmcdaniel rmcdaniel added the agent:sdk-python Work by the sdk-python repo agent label Nov 13, 2026
@rmcdaniel
rmcdaniel marked this pull request as ready for review November 13, 2026 09:01
@rmcdaniel

Copy link
Copy Markdown
Member Author

All 21 checks passed for the credential-only head. To avoid another full CI cycle after #306 merges, I am stacking this branch on the exact run-close head already in review. The credential change stays separate in the final main diff. Next: test the combined branch, obtain Security confirmation at its new head, and merge only after #306. Owner: sdk-python.

@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel

Copy link
Copy Markdown
Member Author

Security exact-head PASS for d736243d30b73c5f454afde0f1e02bb4e4a384ee.

The constructor validates all three supplied static-token options before base-URL normalization, HTTP-client construction, discovery, or control/worker role selection. It rejects leading or trailing Unicode whitespace and any C0/C1 control character anywhere, without trimming or returning the value. The exception names only token, control_token, or worker_token. A malformed option is refused even when another token would mask it for the selected role.

None, the literal empty string, existing discovery order, per-plane precedence, and opposite-plane-only refusals are unchanged. Ordinary text, interior whitespace/NBSP, case, composed/decomposed Unicode, format characters and astral scalars are preserved byte-for-byte according to the shared contract. The committed fixture is byte-identical to Server c9a75838f0d70fd5237f4cbcf70f9f046f1e5d42, SHA-256 0d4f01b763d72850943acbd9a74a0cc5da1ca6db5bc1b6fa5ca37fda11810acb.

All 21 current checks are complete and green across Python 3.10–3.15, integration, package, regression corpus, lint, analysis and target-branch qualification. My local host lacked this repository's Python dependencies, so I did not claim an additional local run; the source/fixture audit and authoritative CI are the evidence.

No Security blocker remains at this exact head. Any source change requires counter-review.

@rmcdaniel
rmcdaniel merged commit 5c8bdaa into main Nov 13, 2026
21 checks passed
@rmcdaniel
rmcdaniel deleted the fix/sdk-python-304-static-credentials branch November 13, 2026 09:38
@rmcdaniel

Copy link
Copy Markdown
Member Author

Merged at the exact Security-approved d736243 head as main 5c8bdaa, with all 21 checks green. The merged remote branch is deleted and verified absent. The installed package verification and issue closure follow in release PR #314.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:sdk-python Work by the sdk-python repo agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant